package com.ttuproject.ttu.controller;

import com.ttuproject.ttu.advice.ResponseEnvelope;
import com.ttuproject.ttu.dao.DistributionTransformerTab;
import com.ttuproject.ttu.dao.InstallationAccount;
import com.ttuproject.ttu.dao.PoleChangeTab;
import com.ttuproject.ttu.exception.Advice;
import com.ttuproject.ttu.service.QueryStationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName QueryStation
 * @Description TODO
 * @Author cw
 * @Date 2021/12/6 11:37
 */
@RestController
@Api(value = "各台区查询接口", tags = "各台区查询接口", description = "各台区查询接口")
public class QueryStationController {

    @Autowired
    QueryStationService queryStationService;

    /**
     * @explain: 杆变台区查看
     * @author: cw
     * @date: 2021/12/7
     */
    //@RequestMapping("/query/station/rod")
    @GetMapping("/query/station/rod")
    @ApiOperation("杆变台区查看")
    public ResponseEntity<ResponseEnvelope<List<InstallationAccount>>> queryrod(@RequestParam("pageNumber") int pageNumber) {
        return ResponseEntity.ok(new ResponseEnvelope<>(Advice.POLE_TRANSFORMER_AREA_SUCCESS, queryStationService.queryrod(pageNumber)));
    }

    /**
     * @explain: 箱变台区查看
     * @author: cw
     * @date: 2021/12/7
     */
    //@RequestMapping("/query/station/box")
    @GetMapping("/query/station/box")
    @ApiOperation("箱变台区查看")
    public ResponseEntity<ResponseEnvelope<List<InstallationAccount>>> querybox(@RequestParam("pageNumber") int pageNumber) {
        return ResponseEntity.ok(new ResponseEnvelope<>(Advice.BOX_TRANSFORMER_STATION_SUCCESS, queryStationService.querybox(pageNumber)));
    }

    /**
     * @explain: 站变台区查看
     * @author: cw
     * @date: 2021/12/7
     */
    //@RequestMapping("/query/station/station")
    @GetMapping("/query/station/station")
    @ApiOperation("站变台区查看")
    public ResponseEntity<ResponseEnvelope<List<InstallationAccount>>> querystation(@RequestParam("pageNumber") int pageNumber) {
        return ResponseEntity.ok(new ResponseEnvelope<>(Advice.SUBSTATION_AREA_SUCCESS, queryStationService.querystation(pageNumber)));
    }

    /**
     * @explain: 配变台区查看
     * @author: cw
     * @date: 2021/12/7
     */
   // @RequestMapping("/query/station/dis")
    @GetMapping("/query/station/dis")
    @ApiOperation("配变台区查看")
    public ResponseEntity<ResponseEnvelope<List<InstallationAccount>>> queryDistributionstation(@RequestParam("pageNumber") int pageNumber) {
        return ResponseEntity.ok(new ResponseEnvelope<>(Advice.DISTRIBUTION_TRANSFORMER_AREA_SUCCESS, queryStationService.queryDistributionstation(pageNumber)));
    }


    /**
     * @explain: 杆变查看详情
     * @author: cw
     * @date: 2021/12/7
     */
    //@RequestMapping("/query/detailed/rod")
    @GetMapping("/query/detailed/rod")
    @ApiOperation("杆变查看详情")
    public ResponseEntity<ResponseEnvelope<PoleChangeTab>> detailedrod(@RequestParam("equipment_name") String equipment_name) {
        return ResponseEntity.ok(new ResponseEnvelope<>(Advice.SELECT_DETAILEDROD_SUCCESS, queryStationService.detailedrod(equipment_name)));
    }

    /**
     * @explain: 配变查看详情
     * @author: cw
     * @date: 2021/12/7
     */
    //@RequestMapping("/query/detailed/distribution")
    @GetMapping("/query/detailed/distribution")
    @ApiOperation("配变查看详情")
    public ResponseEntity<ResponseEnvelope<DistributionTransformerTab>> detailed_distribution(@RequestParam("equipment_name") String equipment_name) {
        return ResponseEntity.ok(new ResponseEnvelope<>(Advice.SELECT_DETAILED_DISTRIBUTION_SUCCESS, queryStationService.detailed_distribution(equipment_name)));
    }

    /**
     * @explain: 杆变台区搜索框
     * @author: 才伟
     * @date: 2022/2/8
     */
    //@RequestMapping("/find/rod")
    @GetMapping("/find/rod")
    @ApiOperation("杆变台区搜索框")
    public ResponseEntity<ResponseEnvelope<List<InstallationAccount>>> findRod(
            @RequestParam(value = "equipment_name", required = false) String equipment_name
    ) {
        return ResponseEntity.ok(new ResponseEnvelope<>(Advice.SELECT_DETAILED_DISTRIBUTION_SUCCESS, queryStationService.findrod(equipment_name)));
    }

    /**
     * @explain: 箱变台区搜索框
     * @author: 才伟
     * @date: 2022/2/8
     */
    //@RequestMapping("/find/box")
    @GetMapping("/find/box")
    @ApiOperation("箱变台区搜索框")
    public ResponseEntity<ResponseEnvelope<List<InstallationAccount>>> findBox(
            @RequestParam(value = "equipment_name", required = false) String equipment_name
    ) {
        return ResponseEntity.ok(new ResponseEnvelope<>(Advice.SELECT_DETAILED_DISTRIBUTION_SUCCESS, queryStationService.findBox(equipment_name)));
    }

    /**
     * @explain: 站变台区搜索框
     * @author: 才伟
     * @date: 2022/2/8
     */
    //@RequestMapping("/find/station")
    @GetMapping("/find/station")
    @ApiOperation("站变台区搜索框")
    public ResponseEntity<ResponseEnvelope<List<InstallationAccount>>> findStation(
            @RequestParam(value = "equipment_name", required = false) String equipment_name
    ) {
        return ResponseEntity.ok(new ResponseEnvelope<>(Advice.SELECT_DETAILED_DISTRIBUTION_SUCCESS, queryStationService.findStation(equipment_name)));
    }

    /**
     * @explain: 配变台区搜索框
     * @author: 才伟
     * @date: 2022/2/8
     */
    //@RequestMapping("/find/distribution")
    @GetMapping("/find/distribution")
    @ApiOperation("配变台区搜索框")
    public ResponseEntity<ResponseEnvelope<List<InstallationAccount>>> findDistribution(
            @RequestParam(value = "equipment_name", required = false) String equipment_name
    ) {
        return ResponseEntity.ok(new ResponseEnvelope<>(Advice.SELECT_DETAILED_DISTRIBUTION_SUCCESS, queryStationService.findDistribution(equipment_name)));
    }
}
